package com.laozhao.EasySales.business;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;

import com.laozhao.EasySales.control.MainWindowsAction;
import com.laozhao.dreamframe.util.FrameFactory;
import com.laozhao.dreamframe.util.ToolsUtil;

public class ToolBarUtil {
	
	public ToolBarUtil(){
		
	}


	public static JPanel loadToolBar() {
		JPanel panel = new JPanel();
		GridLayout gridLayout = new GridLayout(1, 1);
		panel.setLayout(gridLayout);

//		panel.add(getToolBar());
		panel.add(getAddressBar());
		return panel;
//		getContentPane().add(panel, BorderLayout.NORTH);
	}
//	private static JToolBar getToolBar() {
//		JToolBar toolbarFile = new JToolBar();
//		toolbarFile.setName("系统工具");
//
//		JButton toolbarOpen = new JButton(" Open ");
//		JButton toolbarSave = new JButton(" Save ");
//		JButton toolbarShut = new JButton(" ShutDown ");
//
//		toolbarFile.add(toolbarOpen);
//		toolbarFile.add(toolbarSave);
//		toolbarFile.add(toolbarShut);
//		toolbarFile.addSeparator();
//
//		JButton toolbarShut2 = new JButton(" Home ");
//		toolbarFile.add(toolbarShut2);
//
//		// toolbarFile.setBackground(new Color(249, 249, 220));
//		return toolbarFile;
//	}

	private static JToolBar getAddressBar() {
		JToolBar toolbarFile = new JToolBar();
		toolbarFile.setName("Address Bar");

		JButton backBtn = new JButton( new ImageIcon(ToolsUtil.getRoot()+"/img/back.png"));
		backBtn.setPreferredSize(new Dimension(30, 30));
		backBtn.setActionCommand("toolback");
		JButton goBtn = new JButton( new ImageIcon(ToolsUtil.getRoot()+"/img/forward.png"));
		goBtn.setPreferredSize(new Dimension(30, 30));
		goBtn.setActionCommand("toolgo");

		backBtn.addActionListener((ActionListener) FrameFactory.getInstance(MainWindowsAction.class));
		goBtn.addActionListener((ActionListener) FrameFactory.getInstance(MainWindowsAction.class));
		
		toolbarFile.add(backBtn);
		toolbarFile.add(goBtn);
//		JTextField addressText = new JTextField();
//		toolbarFile.add(addressText);

//		JButton toolbarShut2 = new JButton(" Go. ");
//		toolbarFile.add(toolbarShut2);

		 toolbarFile.setBackground(new Color(249, 249, 220));
		return toolbarFile;
	}
}
